﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using Shove.Database;
public partial class SystemManage_OperationLog : PageBase
{
    int count = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
         
            BindData();
        }
    }

    #region Web 窗体设计器生成的代码

    override protected void OnInit(EventArgs e)
    {
        isRequestLogin = true;
        RequestCompetences = Competences.BuildCompetencesList(Competences.Administrator);
        RequestLoginPage = "SystemManage/OperationLog.aspx";

        base.OnInit(e);
    }

    #endregion

    private void BindData()
    {
        string strCmd = "select * from V_LoginLog where [Type] = 2";
        //int QueryTime = Shove._Convert.StrToInt(ddlTime.SelectedValue, -1);

        //if (QueryTime > 0)
        //{
        //    strCmd += " where Datediff(day, [OperatorDate], GetDate()) <= " + QueryTime.ToString();
        //}

        if (TextBox1.Text.Trim() != "")
        {
            strCmd += (strCmd.IndexOf("where") > 0 ? " and" : " where") + " [CustomerNO] = '" + TextBox1.Text.Trim() + "'";
        }

        strCmd += " order by [OperatorDate]";

        DataTable dt = MSSQL.Select(strCmd);

        if (dt == null)
        {
            PublicFunction.GoError(ErrorNumber.DataReadWrite, "数据读写错误", this.GetType().BaseType.FullName);

            return;
        }

        PublicFunction.DataGridBindData(g, dt, gPager);


        //btnClear.Enabled = (dt.Rows.Count > 0);
    }

    protected void g_ItemDataBound(object sender, DataGridItemEventArgs e)
    {

        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.EditItem)
        {
            count++;
            if (count >= 10)
            {
                e.Item.Cells[0].Text = "0" + count;
            }
            else
            {
                e.Item.Cells[0].Text = "00" + count;
            }
        }
    }
    protected void gPager_PageWillChange(object Sender, Shove.Web.UI.PageChangeEventArgs e)
    {
        BindData();
    }
    protected void gPager_SortBefore(object source, DataGridSortCommandEventArgs e)
    {
        BindData();
    }

    protected void ibUser_Click(object sender, ImageClickEventArgs e)
    {
        ViewState["Op"] = "1";
        BindData();
    }

    protected void ibDate_Click(object sender, ImageClickEventArgs e)
    {
        ViewState["Op"] = "0";
        BindData();
    }
}